Strict

Import agfx

Global myTmpScreen:TTmpScreen

Class TAgfx_test_app Extends TFramework

	Method OnCreate:Int()
		
		'DEVICE.SetFps(30)		' default FPS is 60
		
		Super.OnCreate()
		
		
		
		IMAGES.Load("tree.png","TREE",True)
		Self.debug_On = True
		
		myTmpScreen = New TTmpScreen		
		myTmpScreen.Prepare()
		
		Return 0
		
	End Method
	
End


Class TTmpScreen Extends TScreen
	
	Field img_1:TImage
	Field img_2:TImage
	Field sx2:Float = 1
	Field x:Float
	Field y:Float

	Field zoom_w:Int = 160
	Field zoom_h:Int = 100
	
	' START when app is created
	Method Start:Void()
		
		DISPLAY.SetVirtualSize(480,320)
		
		Self.img_1 = IMAGES.Find("TREE")
		Self.img_2 = IMAGES.Find("TREE")
	End Method
	
	' main app logic loop update
	Method Update:Void()
		x = MOUSE.x 
		y = MOUSE.y 
	End Method
	
	' main app render loop
	Method Render:Void()
	
		' SCALE TO 0.5
		
		PushMatrix()
		
			Translate(DISPLAY.VSCREEN_HALF_WIDTH , DISPLAY.VSCREEN_HALF_HEIGHT)
			Scale(0.5,0.5)
			
			Translate(-DISPLAY.VSCREEN_HALF_WIDTH , -DISPLAY.VSCREEN_HALF_HEIGHT) 
			
			Self.img_1.Draw(DISPLAY.VSCREEN_HALF_WIDTH , DISPLAY.VSCREEN_HALF_HEIGHT)
		
		PopMatrix()
		
		' SCALE to ORIGINAL
		
		PushMatrix()

			SetScissor(MouseX() -zoom_w/2,MouseY()-zoom_h/2,zoom_w,zoom_h)

			Translate(DISPLAY.VSCREEN_HALF_WIDTH , DISPLAY.VSCREEN_HALF_HEIGHT)
			Scale(1,1)
			Translate(-DISPLAY.VSCREEN_HALF_WIDTH , -DISPLAY.VSCREEN_HALF_HEIGHT)
			
			Self.img_1.Draw(DISPLAY.VSCREEN_WIDTH-x , DISPLAY.VSCREEN_HEIGHT-y)
			
		PopMatrix()
		
		SetScissor(0,0,DISPLAY.VSCREEN_WIDTH, DISPLAY.VSCREEN_HEIGHT)
		Scale(1,1)
		
	End Method
End



